/**
 *  Copyright 2010 Kyle O'Connor, Justin Arling, Mike Mercieca
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package edu.drexel.sd0910.ece01.aqmon.data;

import com.rapplogic.xbee.api.XBeeAddress64;

/**
 * @author Justin Arling
 * 
 */
public class ActiveNode {

	// Node variables
	private double latitude;
	private double longitude;
	private int rssi;
	private XBeeAddress64 address;
	private String nodeID;

	public ActiveNode(XBeeAddress64 a, String id) {
		setAddress(a);
		setNodeID(id);
		this.latitude = 0;
		this.longitude = 0;
		this.rssi = 0;
	}

	public ActiveNode(XBeeAddress64 a, String id, double lat, double lon) {
		this(a, id);
		setLatitude(lat);
		setLongitude(lon);
		this.rssi = 0;
	}

	public ActiveNode(XBeeAddress64 a, String id, int rssi) {
		this(a, id);
		setRssi(rssi);
		this.latitude = 0;
		this.longitude = 0;
	}

	public ActiveNode(XBeeAddress64 a, String id, int rssi, double lat, double lon) {
		this(a, id, lat, lon);
		setRssi(rssi);
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double lat) {
		this.latitude = lat;
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double lon) {
		this.longitude = lon;
	}

	public int getRssi() {
		return rssi;
	}

	public void setRssi(int rssi) {
		this.rssi = rssi;
	}

	public XBeeAddress64 getAddress() {
		return address;
	}

	public void setAddress(XBeeAddress64 addr) {
		this.address = addr;
	}

	public String getNodeID() {
		return nodeID;
	}

	public void setNodeID(String id) {
		this.nodeID = id;
	}

	@Override
	public String toString() {
		return "ActiveNode [address=" + address + ", latitude=" + latitude + ", longitude=" + longitude + ", nodeID="
				+ nodeID + ", rssi=" + rssi + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		long temp;
		temp = Double.doubleToLongBits(latitude);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(longitude);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((nodeID == null) ? 0 : nodeID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ActiveNode other = (ActiveNode) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (Double.doubleToLongBits(latitude) != Double.doubleToLongBits(other.latitude))
			return false;
		if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude))
			return false;
		if (nodeID == null) {
			if (other.nodeID != null)
				return false;
		} else if (!nodeID.equals(other.nodeID))
			return false;
		return true;
	}
	
}
